﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ProductDetail : System.Web.UI.Page
{
    eStoreDataContext db = new eStoreDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

        string TourName = "";
        string CategoryName = "";
        string LocationName = "";
        int categoryid = Tour.Category.CategoryId;

        int id = int.Parse(RouteData.Values["TourId"].ToString());
        var tourget = db.getDiaDiemByTour(id);

        String Language = Thread.CurrentThread.CurrentCulture.DisplayName;
        if (Language.ToLower().Contains("vietnam"))
        {
            TourName = Tour.NameVN;
            CategoryName = Tour.Category.NameVN;
            var name = db.getNameLocation(id);
           // LocationName = name.Select(p => p.NameVN).ToString();
            foreach (var t in tourget)
            {
                if (LocationName == "")
                {
                    LocationName = "<a href='/" + CategoryName.ToString().ToAscii() + "/" + t.NameVN.ToString().ToAscii() + "-" + t.LocationId + ".html'>" + t.NameVN + "</a>";
                }
                else
                {
                    LocationName += " - " + "<a href='/" + CategoryName.ToString().ToAscii() + "/" + t.NameVN.ToString().ToAscii() + "-" + t.LocationId + ".html'>" + t.NameVN + "</a>";
                }
            }

        }
        else
        {
            TourName = Tour.Name;
            CategoryName = Tour.Category.Name;
            var name = db.getNameLocation(id);
           // LocationName = name.Select(p => p.Name).ToString();
            foreach (var t in tourget)
            {
                if (LocationName == "")
                {
                    LocationName = "<a href='/" + CategoryName.ToString().ToAscii() + "/" + t.NameVN.ToString().ToAscii() + "-" + t.LocationId + ".html'>" + t.NameVN + "</a>";
                }
                else
                {
                    LocationName += " - " + "<a href='/" + CategoryName.ToString().ToAscii() + "/" + t.NameVN.ToString().ToAscii() + "-" + t.LocationId + ".html'>" + t.NameVN + "</a>";
                }
            }
        }
        string chuoi = "<a href='/" + CategoryName.ToString().ToAscii() + "-" + categoryid + ".html'>" + CategoryName + "</a>";
        lblsitemapth.Text = " &raquo; " + chuoi + " &raquo; " + LocationName + " &raquo; " + TourName;
    }

    public Tour Tour
    {
        get
        {
            int id = int.Parse(RouteData.Values["TourId"].ToString());
            var tour = db.Tours.Single(p => p.TourId == id);
            return tour;
        }
    }
    public Travel Travel
    {
        get
        {
            int id = int.Parse(RouteData.Values["TourId"].ToString());
            var travel = db.Travels.Single(p => p.TourId == id);
            return travel;
        }
    }
    public Transport Transport
    {
        get
        {
            var pt = db.Transports.Single(p => p.TransportId == Tour.TransportId);
            return pt;
        }
    }
    public Hotel Hotel
    {
        get
        {
            var hotel = db.Hotels.Single(p => p.HotelId == Tour.HotelId);
            return hotel;
        }
    }
    public String NameS
    {
        get
        {
            String Language = Thread.CurrentThread.CurrentCulture.DisplayName;
            if (Language.ToLower().Contains("vietnam"))
            {
                return Tour.NameVN;
            }
            else
            {
                return Tour.Name;
            }

        }
    }
    public String Descriptionl
    {
        get
        {
            String Language = Thread.CurrentThread.CurrentCulture.DisplayName;
            if (Language.ToLower().Contains("vietnam"))
            {
                return Tour.DescriptionVN;
            }
            else
            {
                return Tour.Description;
            }

        }
    }
}